package com.hut.bms.mapper;

import com.hut.bms.model.BookInfo;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface BookInfoMapper {
    //增加图书sql处理
    @Insert("insert into book_info (book_name, author, `count`, price, publish, `status`) " +
            "values (#{bookName}, #{author}, #{count}, #{price}, #{publish}, #{status})")
    Integer insertByBookInfo(BookInfo bookInfo);
    //获取当前页面的sql处理
    @Select("select id, book_name, author, count, price, publish, status , create_time, update_time " +
            "from book_info where status != 0 limit #{offset}, #{limit}")
    List<BookInfo> queryBookByPage(Integer offset, Integer limit);
    //记录图书中的总数的sql处理
    @Select("select count(1) from book_info where status != 0")
    Integer count();
    //查看图书信息的sql处理
    @Select("select id, book_name, author, count, price, publish, status , create_time, update_time from book_info where id = #{bookId}")
    BookInfo getBookInfoById(Integer bookId);
    //更新图书的信息的sql处理(采用xml的形式)
    Integer updateBookInfo(BookInfo bookInfo);
    //删除图书信息的sql处理
    @Update("update book_info set status = 0 where id = #{bookId}")
    Integer deleteBookInfo(Integer bookId);
    //批量删除图书信息的sql处理(采取xml方式删除)
    Integer batchDeleteBookInfo(List<Integer> ids);
}
